package com.loooooo.pm2024.modules.sys.controller;

import com.loooooo.pm2024.data.Result;
import com.loooooo.pm2024.modules.sys.model.Dict;
import com.loooooo.pm2024.modules.sys.model.DictCatalog;
import com.loooooo.pm2024.modules.sys.selector.DictCatalogSelector;
import com.loooooo.pm2024.modules.sys.selector.DictSelector;
import com.loooooo.pm2024.modules.sys.service.DictCatalogService;
import com.loooooo.pm2024.modules.sys.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/sys/dict/catalog")
public class DictCatalogController {
    @Autowired
    DictCatalogService catalogService;
    ;

    @RequestMapping("/list")
    String listUser() {
        return "sys/dict.catalog.list";
    }

    @PostMapping(value = "/list", consumes = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    Result listUserP(@RequestBody DictCatalogSelector selector) {
        return Result.success(catalogService.list(selector));
    }

    @PostMapping(value = "/update", consumes = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    Result update(@RequestBody DictCatalog user) {
        int r = catalogService.update(user);
        return Result.success(user).set("affect", r);
    }
}
